<route lang="json5" type="page">
{
  layout: 'default',
  style: {
    navigationBarTitleText: '结果',
  },
}
</route>

<template>
  <wd-status-tip
    width="300px"
    height="300px"
    v-if="data.records.length === 0"
    image="../../static/images/search.png"
    tip="当前搜索无结果"
  />
  <view v-else class="p-4 bg-gray-100">
    <view v-for="route in data.records">
      <CardComp :route="route" :key="route.id" />
    </view>
  </view>
</template>

<script lang="ts" setup>
import { Response, routeListAPI } from '@/service/route/route'
import CardComp from '../../pages/index/components/card.vue'
const data = ref<Response>({})
const loading = ref(true)
onLoad(async (opt) => {
  try {
    const res = await routeListAPI(1, 10, opt.keywords)
    data.value = res.result
    console.log(data.value)
    loading.value = false
  } catch (error) {
    console.error('Error fetching route data:', error)
    // 错误处理
  }
})
</script>

<style lang="scss" scoped>
//
</style>
